﻿using System;
using System.Web.Mvc;
using DTcms.Common;

namespace DTcms.Web.Mvc.UI.Page
{
    public partial class usermessage_show : BaseController
    {
        protected int id;
        protected string redirect = string.Empty;//回传地址
        protected Model.user_message model = new Model.user_message();

        /// <summary>
        /// 重写虚方法,此方法在Init事件执行
        /// </summary>
        public usermessage_show()
        {
            id = DTRequest.GetQueryInt("id");
            BLL.user_message bll = new BLL.user_message();
            var userModel = GetUserInfo();
            if (bll.Get(id) == null)
            {
                redirect = linkurl("error", "?msg=" + Utils.UrlEncode("消息不存在！"));
                return;
            }
            model = bll.Get(id);
            if (model.accept_user_name != userModel.user_name && model.post_user_name != userModel.user_name)
            {
                redirect = linkurl("error", "?msg=" + Utils.UrlEncode("消息读取错误！"));
                return;
            }
            //设为已阅读状态
            bll.UpdateFile("id=" + id, "is_read=1,read_time='" + DateTime.Now + "'");
        }
    }
}
